﻿using M_Quality.Domain;
using M_Quality.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace M_Quality.Repository.Impl
{
    public class BaseQIQPRelationRepository : BaseRepository<QIQPRelation>, IQIQPRelationRepository
    {
        public BaseQIQPRelationRepository(MyDbcontract myDbcontract) : base(myDbcontract)
        {
        }

        public async Task<int> AddQIQPRAsync(QIQPRelation qiqpr)
        {
            var gather = await base.GetAsync(x=>x.RawMaterialQualityId==qiqpr.RawMaterialQualityId);
            foreach (var item in gather)
            {
                item.IsDeleted = true;
                await base.UpdateAsync(item);
            }
            var num = await base.AddAsync(qiqpr);
            return num;
        }
    }
}
